import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: pc
 * Date: 2025-02-17
 * Time: 15:45
 */
public class Test {
    //在java当中，没有方法声明一说
    //方法重载
    //1.方法名相同
    //2.参数列表不同(数据类型，个数，顺序)
    //3.返回值不影响方法重载

    public static int add(int a, double b) {
        return (int)(a+b);
    }

    public static double add(double c, int d) {
        return c+d;
    }

    public static void main(String[] args) {

    }
    public static int fac(int n) {
        //阶乘
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }

    public static int facSum(int n) {
        //阶乘和
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += fac(i);
        }
        return sum;
    }

    public static void main4(String[] args) {
        /*int ret = fac(5);
        System.out.println(ret);*/
        System.out.println(facSum(5));//fac(5).sout

    }
    public static boolean isLeapYear(int year) {
        if ( (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ) {
            System.out.println(year + " is leap year");
            return true;
        }
        System.out.println(year + " is not leap year");
        return false;
    }

    /*public static int add(int a, int b) {
        return a + b;
    }*/

    public static void main3(String[] args) {
        int year = 1900;
        isLeapYear(2025);
    }

    public static void main2(String[] args) {
        //求一个二进制的奇偶位
        int n = 7;
        for (int i = 30; i >= 0; i -= 2) {
            System.out.print(((n >> i) & 1) + " ");
        }
        System.out.println();
        for (int i = 31; i >= 1; i -= 2) {
            System.out.print(((n >> i) & 1) + " ");
        }
    }
    public static void main1(String[] args) {
        //输入密码
        int count = 3;
        while (count != 0) {
            System.out.println("请输入你的密码：你还有 " + count +" 次机会！");
            Scanner scan = new Scanner(System.in);

            String pass = scan.nextLine();
            if (pass.equals("123456")) {//判断字符串相等
                //字符串.equals(字符串)
                System.out.println("密码正确!");
                break;
            } else {
                count--;
            }
        }
    }
}
